package com.csap.framework.apidoc.admin.service.impl;

import com.csap.framework.annotation.apidoc.Description;
import com.csap.framework.util.exception.ExceptionUtils;
import com.csap.mybatisplus.extension.service.impl.BaseCsapServiceImpl;
import com.csap.framework.apidoc.admin.model.ApiDocUserModel;
import org.springframework.stereotype.Service;
import com.csap.framework.apidoc.admin.mybatis.ApiDocUserMapper;
import com.csap.framework.apidoc.admin.entity.ApiDocUserEntity;
import com.csap.framework.apidoc.admin.service.ApiDocUserService;

/**
 * <p>
 * 用户信息
 * </p>
 *
 * @author
 * @dateTime
 */
@Service
@Description(value = "用户信息ServiceImpl")
public class ApiDocUserServiceImpl extends BaseCsapServiceImpl<ApiDocUserMapper, ApiDocUserEntity, ApiDocUserModel, Long> implements ApiDocUserService {
    @Override
    public ApiDocUserModel login(ApiDocUserModel apiDocUserModel) {
        return lambdaQuery()
                .eq(ApiDocUserEntity::getUserName, apiDocUserModel.getUserName())
                .eq(ApiDocUserEntity::getPassword, apiDocUserModel.getPassword())
                .eq(ApiDocUserEntity::getDel, Boolean.FALSE)
                .oneOptional()
                .isNullThrow(i -> ExceptionUtils.mpe("账号或密码错误"))
                .transform(ApiDocUserModel.class);
    }
}
